//
//  ZhBasePage.swift
//  Uber
//
//  Created by 朱 桓 on 16/1/6.
//  Copyright © 2016年 zhu.huan. All rights reserved.
//

import UIKit

class ZhBasePage: ZhBaseController {
    
    @IBOutlet var backgroundView:UIView!

    override func viewDidLoad()
    {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
    }

    /**
    *设置导航栏
    *
    *@param title 导航栏按钮文本
    *@param selector 响应函数
    *@param 右上角按钮为true，左上角角按钮false
    */
    func setNavigationItem(title: String,  selector: Selector, isRight: Bool)
    {
        var item:UIBarButtonItem!
        
        // 创建含图片的按钮
        if title.hasSuffix("png") {
            item = UIBarButtonItem(image: UIImage(named: title), style: UIBarButtonItemStyle.Plain, target: self, action: selector)
        }
        else { // 创建含文字的按钮
            item = UIBarButtonItem(title: title, style: .Plain, target: self, action: selector)
        }
        
        item.tintColor = UIColor.darkGrayColor()
        
        if isRight {
            self.navigationItem.rightBarButtonItem = item;
        }
        else {
            self.navigationItem.leftBarButtonItem = item;
        }
    }
    
    func doRight()
    {
        
    }
    
    func doBack()
    {
        if self.navigationController?.viewControllers.count > 1 {
            self.navigationController?.popViewControllerAnimated(true)
        } else {
            self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
        }
    }
}
